package cn.itcast.controller;

import cn.itcast.utils.AliyunOSSOperator;
import cn.itcast.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
@CrossOrigin
public class UploadController {
    @Autowired
    private AliyunOSSOperator aliyunOSSOperator;

    @PostMapping
    public Result upload(@RequestParam("file") MultipartFile file) throws Exception {

        String fileName = aliyunOSSOperator.alibaba(file);
        return Result.success("上传成功", fileName);
    }
}
